using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace GHMC
{
    public partial class NmdNmcPairs : Form
    {
		ListView m_lView;
		List<HMCPair> m_Pair;

        public NmdNmcPairs(ref ListView lView, ref List<HMCPair> Pair)
        {
            InitializeComponent();
			m_lView = lView;
			m_Pair = Pair;
        }

        public void getPair()
        {
			this.ShowDialog();
			return;
        }

		private void addPair()
		{
			if (txtNmc.Text == "" || txtNmd.Text == "")
			{
				MessageBox.Show("Enter both values");
			}
			else
			{
				try
				{
					int NmcInt = int.Parse(txtNmc.Text);
					int NmdInt = int.Parse(txtNmd.Text);
					ListViewItem l = new ListViewItem(txtNmd.Text);
					l.SubItems.Add(txtNmc.Text);

					m_lView.Items.Add(l);

					HMCPair p = new HMCPair(NmdInt, NmcInt);
					m_Pair.Add(p);
				}
				catch (Exception)
				{
					MessageBox.Show("Nmc and Nmd must be both be ints");
				}
			}
		}

        private void cmdAdd_Click(object sender, EventArgs e)
        {
			addPair();
            this.Close();
        }

		private void cmdCancel_Click(object sender, EventArgs e)
		{
			this.Close();
		}
    }
}